from functools import wraps
from utils.middlewares.LogMiddleWare import local


# 定义装饰器, 用于往local中添加信息
def add_attr(**attrs):
    def decorator(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            ret = func(*args, **kwargs)
            for k, v in attrs.items():
                setattr(local, k, v)
            return ret

        return wrapper

    return decorator
